<?php 
define('__ROOT__', dirname(dirname(__FILE__))); 
include_once(__ROOT__.'/includes/header.php'); 
include_once(__ROOT__.'/includes/leftnav.php');
 
if (isset($message)){
	echo '<div class="notification msginfo">';
	echo '<a class="close"></a>';
	echo $message;
	echo '</div>';
}
?>

<div id="content" class="span10">
	<ul class="breadcrumb">
					<li>
						<a href="<?php echo base_url('/home'); ?>">Home</a> <span class="divider">/</span>
					</li>
					<li>
						<a href="<?php echo base_url('/admin/dashboard'); ?>">Dashboard</a> <span class="divider">/</span>
					</li>
					<li>
						Broadcast
					</li>
	</ul>
	<div class="row-fluid">
		<?php echo $this->session->userdata('name'); ?>
		<div class="well" style="padding: 8px 10px;">
				<?php 
				   // $action = base_url('admin/dashboard/broadcast');
					$action = '';
					$attributes = array('class' => 'form-horizontal' , 'id' => 'broadcastfrm');
					echo form_open_multipart($action, $attributes);?>
				<fieldset>
					<legend>Broadcast message to portal members</legend>
					<input type="hidden" id="userid" value="<?php echo $this->session->userdata('userid'); ?>">
					<input type="hidden" id="url" value="<?php echo base_url(); ?>admin/message/" >
					<div class="control-group">
					  <label class="control-label" for="subject">Subject</label>
					  <div class="controls">
						<input type="text" id="subject" class="text ui-widget-content ui-corner-all" >
					  </div>
					</div>
					<div class="control-group">
					  <label class="control-label" for="body">Body</label>
					  <div class="controls">
						<textarea rows="3" id="body"></textarea>
					  </div>
					</div>
					<div class="control-group">
					  <label class="control-label" for="userfile">Upload Attachment</label>
					  <div class="controls">
						<input data-no-uniform="true"
						type="file" name="userfile" id="file_upload" />
					  </div>
					</div>
				</fieldset>
				<a id="broadcast" class="btn btn-primary">Broadcast</a>
			</div>
			<div class="row-fluid">
				<table class="table table-striped" id="broadcastlist">
					<tbody>
						<tr>
							<th>ID</th>
							<th>Subject</th>
							<th>Posted DateC</th>
							<th> Actions</th>
						</tr>
					</tbody>	
				</table>
			</div>
		</div>
	</div>
</div>

<?php 

include_once(__ROOT__.'/includes/footer.php');
?>
 <script type="text/javascript" src="<?php echo base_url("assets/js/jquery.sparkline.min.js"); ?>"></script>
<script>
//Form submission jqery code under js/external.js file.
//the following code will execute while on page load
$(document).ready(function() {
			
	var myid = <?php echo $this->session->userdata('userid'); ?>;
	var url = $("#url").val();
	var sendData = { 
				'userid': myid 
		};
			
		$.ajax({
					type: "post",
					url: url+"oldbroadcasts",
					cache: false,
					data: sendData,
					success: function(data) {
						var obj = $.parseJSON(data);
						addNewBroadcast(obj);	
					}
				});
	});

</script>